package softtech.apps.callblocker.model;

import android.content.ContentValues;
import android.database.Cursor;

public class Setting {
	
	public  static final String TABLE_NAME = "Setting";
	
	private int id;
	public static final String ID = "id" ;
	
	private String passCode;
	public static final String PASS_CODE = "passCode";
	
	private String passFakeCode;
	public static final String PASS_FAKE_CODE = "passFakeCode";
	
	private int defaultModel;
	public static final String DEFAULT_MODE = "defaultMode";
	
	private int blockCallSetting;
	public static final String BLOCK_CALL_SETTING = "blockCallSetting";
	
	private int blockSmsSetting;
	public static final String BLOCK_SMS_SETTING = "blockSmsSetting";
	
	
	public Setting() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	public Setting(int id, String passCode, String passFakeCode,
			int defaultModel, int blockCallSetting, int blockSmsSetting) {
		super();
		this.id = id;
		this.passCode = passCode;
		this.passFakeCode = passFakeCode;
		this.defaultModel = defaultModel;
		this.blockCallSetting = blockCallSetting;
		this.blockSmsSetting = blockSmsSetting;
	}
	
	public Setting(String passCode, String passFakeCode,
			int defaultModel, int blockCallSetting, int blockSmsSetting) {
		super();
		this.passCode = passCode;
		this.passFakeCode = passFakeCode;
		this.defaultModel = defaultModel;
		this.blockCallSetting = blockCallSetting;
		this.blockSmsSetting = blockSmsSetting;
	}


	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getPassCode() {
		return passCode;
	}

	public void setPassCode(String passCode) {
		this.passCode = passCode;
	}

	public String getPassFakeCode() {
		return passFakeCode;
	}

	public void setPassFakeCode(String passFakeCode) {
		this.passFakeCode = passFakeCode;
	}

	public int getDefaultModel() {
		return defaultModel;
	}

	public void setDefaultModel(int defaultModel) {
		this.defaultModel = defaultModel;
	}

	public int getBlockCallSetting() {
		return blockCallSetting;
	}

	public void setBlockCallSetting(int blockCallSetting) {
		this.blockCallSetting = blockCallSetting;
	}

	public int getBlockSmsSetting() {
		return blockSmsSetting;
	}

	public void setBlockSmsSetting(int blockSmsSetting) {
		this.blockSmsSetting = blockSmsSetting;
	}
	/**
	 * get values of Setting 
	 * @return ContentValues values
	 */
	public ContentValues getValuesSetting(){
		ContentValues values = new ContentValues();
		
		values.put(DbConstant.PASS_CODE, this.getPassCode());
		values.put(DbConstant.PASS_FAKE_CODE, this.getPassFakeCode());
		values.put(DbConstant.DEFAULT_MODE, this.getDefaultModel());
		values.put(DbConstant.BLOCK_CALL_SETTING, this.getBlockCallSetting());
		values.put(DbConstant.BLOCK_SMS_SETTING, this.getBlockSmsSetting());
		
		return values;
	}
	
	/**
	 * Set value for Setting from cursor
	 * @param cursor
	 * @return setting
	 */
	public static Setting SetValueFromCursor(Cursor cursor){
		Setting setting = new Setting();
		setting.setId(cursor.getInt(cursor.getColumnIndex(DbConstant.ID)));
		setting.setBlockCallSetting(cursor.getInt(cursor.getColumnIndex(DbConstant.BLOCK_CALL_SETTING)));
		setting.setBlockSmsSetting(cursor.getInt(cursor.getColumnIndex(DbConstant.BLOCK_SMS_SETTING)));
		setting.setDefaultModel(cursor.getInt(cursor.getColumnIndex(DbConstant.DEFAULT_MODE)));
		setting.setPassCode(cursor.getString(cursor.getColumnIndex(DbConstant.PASS_CODE)));
		setting.setPassFakeCode(cursor.getString(cursor.getColumnIndex(DbConstant.PASS_FAKE_CODE)));

		return setting;
	}
	
	public String toString(){
		return "Setting : " + this.getId() + " " + this.getPassCode() + " "+
				this.getPassFakeCode() + " " + this.getDefaultModel() + " " 
				+this.getBlockCallSetting() + " " + this.getBlockSmsSetting();
	}
}
